#include<iostream>
#include<vector>

#define N 9

using namespace std;

int c;
vector<int> location;

bool check(int i,int j)
{
    for(int k=0;k<location.size();k++)
    {
        int x=k;
        int y=location[k];
        if(x==i||y==j) return false;
        if(x-i+j-y==0 || x-i-j+y==0) return false;
    }
    return true;
}

void queen(int i)
{
    if(i==N) c++;
    for (int j=0;j<N;j++)
    {
        if(check(i,j))
        {
            location.push_back(j);
            queen(i+1);
            location.pop_back();
        }
    }
}

int main()
{
    c =0;
    queen(0);
    cout<<c;
}